package com.jy.it.ui.admin;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONArray;
import com.jy.it.service.ReportSerive;
import com.jy.it.service.impl.ReportServiceImpl;

@Controller
public class ReportController {
	@Autowired
	private ReportSerive service=new ReportServiceImpl();
	
	@RequestMapping("/admin/report/rule")
	public String showReportRule(Model m) {
		List<Map<String,Object>> datas=service.findReportRule();
		String json=JSONArray.toJSONString(datas);//集合转成Jason格式
		m.addAttribute("datajson",json);
		
		List<String> names=new ArrayList<String>();
		for(Map<String,Object> map:datas) {
			names.add((String) map.get("name"));	
		}
		String json1=JSONArray.toJSONString(names);//集合转成Jason格式
		m.addAttribute("namejson",json1);
		return "admin/report_rule";
	}
	@RequestMapping("/admin/report/score")
	public String showReportScore(Model m) {
		List<Map<String,Object>> datas=service.findReportScore();
		String json=JSONArray.toJSONString(datas);//集合转成Jason格式
		m.addAttribute("datajson",json);
		
		List<String> names=new ArrayList<String>();
		for(Map<String,Object> map:datas) {
			names.add((String) map.get("name"));	
		}
		String json1=JSONArray.toJSONString(names);//集合转成Jason格式
		m.addAttribute("namejson",json1);
		return "admin/report_score";
	}
}
